/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package rosedb.gui;

import com.explodingpixels.macwidgets.HudWidgetFactory;
import com.explodingpixels.macwidgets.HudWindow;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;


/**
 *
 * @author riu
 */
public class DeleteRoseDialog extends HudWindow{

    private MainFrame gui;
    private JPanel contentPane = new JPanel(new BorderLayout(0, 20));
    private JButton btn_ok;
    private JButton btn_abort;
    
    private boolean disposed = false;


    public static enum Answer{
        YES, NO;
    }

    private Answer answer = Answer.NO;

    public DeleteRoseDialog(String m, MainFrame gui) {
        super(m, gui);
        
        setContentPane(contentPane);
        getJDialog().setSize(200, 100);
        getJDialog().setModal(true);
        getJDialog().setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        init();
        getJDialog().setLocation(gui.getX()+gui.getWidth()/2-getJDialog().getWidth()/2, gui.getY()+gui.getHeight()/2-getJDialog().getHeight()/2);
        getJDialog().setVisible(true);
    }



    private void init(){
        btn_ok = HudWidgetFactory.createHudButton("Löschen");
        btn_ok.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                answer = Answer.YES;
                DeleteRoseDialog.this.getJDialog().setVisible(false);
            }
        });


        btn_abort = HudWidgetFactory.createHudButton("Abbrechen");
        btn_abort.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                answer = Answer.NO;
                DeleteRoseDialog.this.getJDialog().setVisible(false);
            }
        });

        JLabel m;
        contentPane.add(m = HudWidgetFactory.createHudLabel("wirklich löschen?"), BorderLayout.NORTH);
        m.setHorizontalAlignment(JLabel.CENTER);

        contentPane.add(btn_abort, BorderLayout.EAST);
        contentPane.add(btn_ok, BorderLayout.WEST);
        contentPane.setOpaque(false);
    }


    public void dispose(){
        getJDialog().dispose();
        disposed = true;
    }

    public boolean isDisposed() {
        return disposed;
    }

    public Answer getAnswer() {
        return answer;
    }
}
